Skip to content

Fix for Mantis 3115#358

Closed
asarium wants to merge 1 commit into
scp-fs2open:masterfrom
asarium:mantis/3115
Closed

Fix for Mantis 3115#358
asarium wants to merge 1 commit into
scp-fs2open:masterfrom
asarium:mantis/3115

Conversation

@asarium

@asarium asarium commented Sep 23, 2015

Copy link
Copy Markdown
Member

This is based on the patch uploaded by MageKing17 and adds a polymodel flag that indicates that a model uses look_at

This is currently untested as I can't create a mission containing the test model (no FRED on linux).

@asarium asarium added mantis A feature or issue imported from MANTIS, the old issue tracker unfinished (Deprecated by PR Drafts) A feature or issue that's unfinished, but still wants feedback/review labels Sep 23, 2015
@asarium asarium added this to the Release 3.7.4 milestone Sep 23, 2015
Comment thread code/model/modelread.cpp

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to remove one of the two $gun_rotation checks? I notice that there are two duplicate checks but the $dumb_rotate check is missing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose the $gun_rotation: check is redundant with the $gun_rotation check, but I intentionally removed the $dumb_rotate check because it's made irrelevant by moving this check to below where $dumb_rotate is handled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so; the $dumb_rotate block doesn't assign pm->submodel[n].can_move = true;.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to; it sets movement_type to something other than MOVEMENT_TYPE_NONE so this block (setting can_move) still executes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I missed the movement_type clause in the condition. Fair enough.

@Goober5000

Copy link
Copy Markdown
Contributor

I commented on one part that doesn't look quite right. Aside from that the patch looks okay, but this is just a minimal functionality hook. Is someone going to investigate merging the look-at functionality into one of the existing hierarchy traversals? It looks to me like all that's needed is to add submodel_look_at in the appropriate spot.

EDIT: well, okay, m!m said "I'm also not sure if my usage of model_look_at is right in model_render_queue" in the Mantis ticket, and I too am not sure if model_look_at was added to the right function. This needs testing.

@Goober5000

Copy link
Copy Markdown
Contributor

I've gotten back in touch with Vasudan Admiral. He will provide the model and a test mission.

Once I have the test assets in hand, I plan to test both this patch as well as an alternative patch that merges the look_at functionality in an existing traversal.

@Goober5000

Copy link
Copy Markdown
Contributor

I spent quite some time today looking at this, and I now have a better handle on this part of the code, although it's unclear exactly why we have both polymodels and polymodel_instances. I thought it was similar to ship_info and ship but it's not.

At the very least, we should be able to merge the look_at traversal into the dumb_rotation traversal; the two are almost identical. But I want to see how far down the rabbit hole this model_instance thing goes.

@asarium

asarium commented Nov 16, 2015

Copy link
Copy Markdown
Member Author

I think the ploymodel_instance contains information about the rotations of one instance (e.g. a specific ship) of the model.

@Goober5000

Copy link
Copy Markdown
Contributor

That's what I thought initially, but the code is rotating submodels on the polymodel, not the polymodel_instance.

@Goober5000

Copy link
Copy Markdown
Contributor

Yep, it's a rabbit hole. And it will require a bit of work to climb out of.

I will update again tomorrow.

@asarium

asarium commented Nov 17, 2015

Copy link
Copy Markdown
Member Author

I remember that polymodel_instance is a relatively new addition. Previously the submodels of the polymodel were changed but now most of the code uses the instance method. The look at code probably was written before that system was introduced.

@Goober5000

Copy link
Copy Markdown
Contributor

You're right -- polymodel_instance does not appear in the original public release. Do you know why that was changed?

@asarium

asarium commented Nov 17, 2015

Copy link
Copy Markdown
Member Author

Copying the rotation information into the model was very performance intensive. Most operations (e.g. determining the global position of a point that is relative to a subobject) only needed the rotation information so that was separated from the rest and the simple computations could be done using only the instance.
However, I'm not entirely sure if that is the actual reason, it is just what I was told the last time I made a model related patch.

This is based on the patch uploaded by MageKing17 and adds a polymodel flag that indicates that a model uses look_at
@Goober5000

Copy link
Copy Markdown
Contributor

Made some progress, in consultation with Swifty. Some refactoring needed, but the end result should be more robust and should align with the design for the rest of the model code.

@asarium

asarium commented Dec 13, 2015

Copy link
Copy Markdown
Member Author

What's the status of the refactor? I took the idea of combining look_at and dumb rotations and implemented it here: master...asarium:mantis/3115_2

@Goober5000

Copy link
Copy Markdown
Contributor

The dumb_rotation refactor is done; the look_at refactor is not far behind. You can see the status of dumb_rotation in my branch here:
https://github.com/Goober5000/fs2open.github.com/tree/dumb_rotation_refactor

Unfortunately, Swifty's time is limited, which is what is causing all the delays. One of the problems is that the original implementation of model_instances back in 2010 was only done for collision detection, not for rendering or other miscellaneous uses. Swifty added the rendering implementation in #486 and #496, so only a little bit more work remains. He said he'd give me a status update on Friday, but I haven't heard from him yet, so I'll ping him again.

The bottom line is that the refactoring is making excellent, albeit slow, progress. Once the prerequisites from Swifty are done, I'll merge in the dumb_rotation refactor. Then it should be a very small additional effort to complete the look_at refactor as well. The end result will be code that is in much better shape, without ugly and inefficient hacks to graft on specialized functionality.

@asarium

asarium commented Dec 13, 2015

Copy link
Copy Markdown
Member Author

Alright. Does it make sense to still include this in the 3.7.4 release? Without this we could release 3.7.4 soon and focus on stabilizing antipodes.

@Goober5000

Copy link
Copy Markdown
Contributor

Urgh. I'd like to keep this in 3.7.4, simply because a) the look_at feature has been deferred for several releases, and it would be nice to finally actually include it; and b) this would tie up the submodel code with a nice bow instead of leaving things half-done.

I wish things were moving along faster myself, but we are making regular and consistent progress, and we have only a few steps remaining before this is complete. So I'd ask for a bit more time.

@Goober5000

Copy link
Copy Markdown
Contributor

Swifty responded today. We ran into a problem which could have been avoided if the dumb_rotation feature had been coded properly in the first place. :-/ But we found a way around it and hopefully Swifty will be able to complete his prerequisite shortly.

@Goober5000

Copy link
Copy Markdown
Contributor

Swifty submitted PR #501. Once that's reviewed, I should be able to add the dumb_rotation pretty quickly. The look_at change will take a little bit more time but should also be doable in the very short term.

@MageKing17

Copy link
Copy Markdown
Member

Closing in favour of PR #530.

@MageKing17 MageKing17 closed this Feb 1, 2016
@asarium asarium deleted the mantis/3115 branch November 23, 2016 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mantis A feature or issue imported from MANTIS, the old issue tracker unfinished (Deprecated by PR Drafts) A feature or issue that's unfinished, but still wants feedback/review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants